﻿namespace MvcXRepairCustomer.Services
{
    using System;
    using System.Collections.Generic;
    using MvcXRepairCustomer.Interfaces;
    using MvcXRepairCustomer.Repository.SQL;
    using XRepair.Models;

    public class StateService : IStateService
    {
        private StateDAO _stateRepository;

        public StateService()
        {
            _stateRepository = new StateDAO();
        }

        public IEnumerable<State> GetAllActiveStates()
        {
            return _stateRepository.GetAllActiveStates();
        }

        public bool DeactivateStateByID(int stateId)
        {
            return _stateRepository.DeactivateStateByID(stateId);
        }

        public bool AddNewState(State state)
        {
            state.CreatedAt = DateTime.Now;
            return _stateRepository.AddNewState(state);
        }

        public bool UpdateState(State state)
        {
            state.LastUpdatedAt = DateTime.Now;
            return _stateRepository.UpdateState(state);
        }
    }
}
